import { readFileSync } from 'fs';
import { resolve } from 'path';
import { networkInterfaces } from 'os';

const buffer = readFileSync(resolve('package.json'));
const packages = JSON.parse(buffer.toString());

const networks = networkInterfaces();
const networkList: string[] = [];
Object.keys(networks).forEach((key) => {
  // @ts-ignore
  networks[key] = networks[key].filter((item) => item.family === 'IPv4');
  // @ts-ignore
  networks[key] = networks[key].map((item) => item.address);
  // @ts-ignore
  networkList.push(networks[key][0]);
});

// tips 项目名称
export const project = packages.name;
// tips 网络ipv4地址
export const host = networkList;
